import { getAreaObj, uploadType } from '@/utils/util'

export const searchConfig = {
	inline: true,
	showBtn: true,
	labelPosition: 'left',
	column: [
		{
			label: '所属地区',
			prop: 'areas',
			type: 'AplidAreaSelect',
			span: 8,
		},
		{
			label: '所属单位',
			prop: 'organizationName',
			type: 'input',
			span: 8,
		},
		{
			label: '摄像头位置',
			prop: 'videoLocation',
			span: 8,
			type: 'remoteSelect',
			code: 'VIDEO_LOCATION',
			api: 'getDictItemList',
			filterKey: 'value',
			multiple: false,
		},
		{
			label: '抽查问题内容',
			prop: 'videoContent',
			type: 'input',
			span: 8,
		},
		{
			label: '整改状态',
			prop: 'rectificationStatus',
			type: 'select',
			span: 8,
			dicData: [
				{
					label: '已整改',
					value: 1,
				},
				{
					label: '待整改',
					value: 2,
				},
			],
		},
	],
}

export const spotCheckForm = {
	inline: false,
	showBtn: true,
	labelPosition: 'top',
	labelWidth: '0',
	column: [
		{
			type: 'DividerHtml',
			labelPosition: 'top',
			position: 'center',
			modelValue: '抽查问题的图片',
			span: 24,
		},
		{
			label: '抽查人',
			prop: 'scUserName',
			disabled: true,
			span: 24,
		},
		{
			label: '',
			prop: 'videoPic',
			type: 'upload',
			// fileType: uploadType.fileMetaType,
			listType: 'picture-card',
			labelPosition: 'top',
			showFileList: true,
			limit: 4,
			multiple: true,
			span: 24,
			onlyReady: true,
		},
		{
			type: 'DividerHtml',
			labelPosition: 'top',
			position: 'center',
			modelValue: '抽查问题内容',
			span: 24,
		},
		{
			label: '',
			prop: 'videoContent',
			type: 'textarea',
			maxlength: '500',
			rows: 1,
			disabled: true,
			showWordLimit: true,
			span: 24,
		},

		{
			type: 'DividerHtml',
			labelPosition: 'top',
			position: 'center',
			modelValue: '整改图片',
			span: 24,
		},
		{
			label: '',
			prop: 'rectificationPic',
			type: 'upload',
			// fileType: uploadType.fileMetaType,
			listType: 'picture-card',
			labelPosition: 'top',
			showFileList: true,
			limit: 4,
			multiple: true,
			span: 24,
		},
		{
			type: 'DividerHtml',
			labelPosition: 'top',
			position: 'center',
			modelValue: '整改内容',
			span: 24,
		},
		{
			label: '',
			prop: 'rectificationContent',
			type: 'textarea',
			maxlength: '500',
			rows: 1,
			showWordLimit: true,
			span: 24,
		},
	],
}

export const tableConfig = {
	stripe: true,
	border: true,
	columns: [
		{ label: '所属区', prop: 'areaName' },
		{ label: '所属单位', prop: 'organizationName' },
		{ label: '摄像头位置', prop: 'videoLocation', code: 'VIDEO_LOCATION' },
		{ label: '抽查问题内容', prop: 'videoContent' },
		{ label: '抽查问题图片', prop: 'videoPic', custome: 'file' },
		{
			label: '整改状态',
			prop: 'rectificationStatus',
			custome: 'tag',
			dicData: [
				{
					label: '已整改',
					value: 1,
					type: 'success',
				},
				{
					label: '待整改',
					value: 2,
					type: 'danger',
				},
			],
		},
		{ label: '摄像头地址', prop: 'videoPlay' },
		{
			label: '操作',
			prop: 'menu',
			width: 200,
			fixed: 'right',
		},
	],
}

export const api = {
	index: 'view_scSpotCheckMonitor_page',
	edit: 'view_scSpotCheckMonitor_edit',
	detail: 'view_scSpotCheckMonitor_view',
	authArea: 'authArea',
}
export const baseConfig = {
	pageName: '抽查记录',
	dictcodes: ['VIDEO_LOCATION'],
	rowKey: 'id',
	addLabel: '新增',
	tipLabel: 'organizationName',
	exportMqTopic: '/ning/export/',
	api,
	auth: {
		...api,
		mulitSet: 'mulitSet',
	},
	paramsObj: {
		source: 1,
	},
	menuBtn: [
		{
			icon: 'editor',
			label: '整改',
			type: 'primary',
			operate: 'edit',
			auth: api.edit,
			text: true,
			show: true,
			condition: '(row)=>row.rectificationStatus ==2',
		},
		{
			icon: 'detail',
			label: '详情',
			type: 'primary',
			operate: 'detail',
			auth: api.index,
			text: true,
			show: true,
		},
	],
	dialogConfig: {
		width: '55%',
	},
	searchConfig,
	tableConfig,
	beforeOnLoadFormate: async (params) => {
		return new Promise((resolve, reject) => {
			const areaObj: any = getAreaObj(params.areas)
			resolve({
				...params,
				...areaObj,
				areas: undefined,
			})
		})
	},
}
